/*require("ui.js")
* */
var BattleUI = (function(){
    var id_ui = ".gameUI .battleUI";
    var id_accept = ".battleUI #acceptButton";
    var id_selfName = ".battleUI #player1Name";
    var id_selfWuli = ".battleUI #player1Wuli";
    var id_selfHp = ".battleUI #hpText1";
    var id_selfFace = ".battleUI #player1Header";
    var id_enemyName = ".battleUI #player2Name";
    var id_enemyWuli = ".battleUI #player2Wuli";
    var id_enemyHp = ".battleUI #hpText2";
    var id_enemyFace = ".battleUI #player2Header";
    var id_bottomInfo = ".battleUI #bottomInfo";
    var id_middleInfo = ".battleUI #middleInfo";

    var id_changeDefense = ".battleUI #attackOrDefenseButton";

    var defense = false;
    return {
        name:"BattleUI",
        hide:function(){
            addClassWithCheck(id_ui,"hide");
        },
        show:function(){
            removeClassWithCheck(id_ui,"hide");
            BattleUI.registerEvent();
        },
        onAccept:function(cb){
            $(id_accept).click(function(){
                executeWhenEnable(id_accept,cb);
            });
        },
        disableAccept:function(){
            addClassWithCheck(id_accept,"disable");
        },
        enableAccept:function(){
            removeClassWithCheck(id_accept,"disable");
        },
        onChangeDefense:function(cb){
            $(id_changeDefense).click(function(){
                BattleUI.toggleAttackDefenese();
                cb();
            });
        },
        changeDefense:function(){
            addClassWithCheck(id_accept,"defense");
            addClassWithCheck(id_bottomInfo,"defense");
            addClassWithCheck(id_middleInfo,"defense");
            defense = true;
        },
        changeAttack:function(){
            removeClassWithCheck(id_accept,"defense");
            removeClassWithCheck(id_bottomInfo,"defense");
            removeClassWithCheck(id_middleInfo,"defense");
            defense = false;
        },
        toggleAttackDefenese:function(){
            if(defense){
                BattleUI.changeAttack();
            }else{
                BattleUI.changeDefense();
            }
        },
        isDefense:function(){
            return defense;
        },
        setSelfFace:function(face){
            $(id_selfFace).attr("background",face);
        },
        setEnemyFace:function(face){
            $(id_enemyFace).attr("background",face);
        },
        setSelfName:function(name){
            $(id_selfName).html(name);
        },
        setEnemyName:function(name){
            $(id_enemyName).html(name);
        },
        setSelfHp:function(hp){
            $(id_selfHp).html(hp);
        },
        setEnemyHp:function(hp){
            $(id_enemyHp).html(hp);
        },
        setSelfWuli:function(wuli){
            $(id_selfWuli).html(wuli);
        },
        setEnemyWuli:function(wuli){
            $(id_enemyWuli).html(wuli);
        },
        registerEvent:function(){

        },
    }
})();

UISystem.registerUI(BattleUI.name,BattleUI);